package stackmachine.command;

import stackmachine.IP;
import stackmachine.StackItem;
import stackmachine.command.Command;

import java.util.LinkedList;

public class OutCommand extends Command {
    @Override
    public boolean commit(LinkedList<StackItem> stack, LinkedList<StackItem> out, IP ip) {
        StackItem item = stack.pollLast();
        if (item == null) {
            return false;
        }
        out.addLast(item);
        ip.increment();
        return true;
    }
}
